#ifndef OBJECT_H
#define OBJECT_H

#include <Core/drawable.h>
#include <Util/Vec3.h>
#include <Util/Aabb.h>
#include <QString>

namespace Core{
    class Square;

    /*! \class Object
      * \brief Global objects management
      * \author Anthony BIGOT & Vincent LOPPIN
      * \version 1.0
      *
      * Inherits Drawable
      *
      */
    class Object : public Drawable
    {
    public :

        /*** LIFECYCLE ***/
        Object(const QString & filename = "");
        Object(const Object &ref);
        ~Object(){}

        /*** OPERATIONS ***/

        /// Draw the mesh representing the object (or a sphere if no mesh)
        void draw() const;

        /*** ATTRIBUTE ACCESSORS ***/

        /// Set the mesh used
        //void setMesh(const QString &filename);
        /// Remove the mesh (draw a sphere instead)
        //void removeMesh();
        /// Return a const pointer on the mesh used (null if no mesh used)
        //inline const Rendering::Mesh * getMesh() const { return mesh; }
        /// Return the bounding box of the object
        inline const Aabb & getBound() const { return aabb; }

        /// Return true if the bounding box is drawn with the object
        inline bool getBoundIsDrawn() const { return drawAabb; }
        /// Show the bounding box with the object
        inline void setDrawBound(bool drawBound) { drawAabb = drawBound; }

        /// Return the image used as 2D representation of the object
        inline const QImage & getImage2D() const { return img2d; }
        /// Set the image used as 2D representation of the object
        inline void setImage2D(const QImage &img) { img2d = img; }

        /// Set the parent square
        inline void setParentSquare(Square * parent) { parentSquare = parent; }
        /// Return the parent square
        inline Square * getParentSquare() const { return parentSquare; }

        /// Set the object Position
        ///\param pos new position
        inline void setPosition(Vec3d & pos){ position = pos; }
        /// Return the object Position
        inline Vec3d & getPosition(){ return position; }

        /// Set the scale
        inline void setScale(double scale) { scale = scale; }
        /// Return the current scale
        inline double getScale() const { return scale; }

    protected :
        Square *			parentSquare;	///< Square on which the object is
        //Rendering::Mesh *	mesh;			///< 3D Mesh representing the object
        Aabb                aabb;			///< Bounding box enclosing the mesh
        QImage              img2d;          ///< 2D representation of the object (used for top view)
        double				scale;          ///< Scale to apply
        bool				drawAabb;		///< Display the bounding box or not
        Vec3d				position;

         /// Draw the element with texture
        void drawWithTexture() const;
        /// Draw the element with color
        void drawWithColor() const;
        /// Draw the element with the attached 2D picture
        void drawIn2D() const;
    };

}
#endif // OBJECT_H
